package com.ssy.lingxi.product.repository;

import com.ssy.lingxi.product.entity.PriceCurveSet;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * 价格曲线设置持久化层
 * @author jw.chen
 * @version 2.0.0
 * @date 2021/10/20
 */
public interface PriceCurveSetRepository extends JpaRepository<PriceCurveSet,Long>, JpaSpecificationExecutor<PriceCurveSet> {
    List<PriceCurveSet> findByMemberIdAndMemberRoleId(Long memberId, Long memberRoleId);

    Boolean existsByMemberIdAndMemberRoleIdAndShopIdAndStatus(Long memberId, Long memberRoleId, Long shopId, Boolean status);

    @Query("select memberId, memberRoleId from PriceCurveSet where status = ?1 group by memberId, memberRoleId")
    List<Object[]> findByStatusGroupByMemberIdAndMemberRoleId(Boolean status);
}
